﻿
using Microsoft.Extensions.Logging;
using NLog;
using NLog.Extensions.Logging;

namespace EFCoreLock;

public class SqlContext:DbContext
{
    private static ILoggerFactory loggerFactory = LoggerFactory.Create(p=>p.AddNLog());
    public DbSet<Employee> Employees { get; set; }
    public DbSet<Work> Works { get; set; }
    public DbSet<House> Houses { get; set; }
    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
    {
        base.OnConfiguring(optionsBuilder);
        optionsBuilder.UseSqlServer("server=localhost;database=db0801; integrated security =true; Encrypt = false;");
        optionsBuilder.UseLoggerFactory(loggerFactory);
    }

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        base.OnModelCreating(modelBuilder);
        modelBuilder.ApplyConfigurationsFromAssembly(this.GetType().Assembly);
    }
}
